package com.jie.jie.yunxin;

import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.jaydenxiao.common.base.BaseActivity;
import com.jaydenxiao.common.commonutils.LogUtils;
import com.jie.jie.R;
import com.netease.nimlib.sdk.NIMClient;
import com.netease.nimlib.sdk.RequestCallback;
import com.netease.nimlib.sdk.auth.AuthService;
import com.netease.nimlib.sdk.auth.LoginInfo;

import butterknife.Bind;
import butterknife.OnClick;

public class YLoginActivity extends BaseActivity {


    @Bind(R.id.back_iv)
    ImageView backIv;
    @Bind(R.id.title_tv)
    TextView titleTv;
    @Bind(R.id.yl_accid)
    EditText ylAccid;
    @Bind(R.id.yl_login)
    Button ylLogin;
    @Bind(R.id.activity_ylogin)
    LinearLayout activityYlogin;

    @Override
    public int getLayoutId() {
        return R.layout.activity_ylogin;
    }

    @Override
    public void initPresenter() {

    }

    @Override
    public void initView() {

    }


    @OnClick({R.id.back_iv, R.id.yl_login})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.back_iv:
                finish();
                break;
            case R.id.yl_login:
                doLogin();

                break;
        }
    }
    public void doLogin() {
        LoginInfo info = new LoginInfo("615243","c2af78be8cf108699b09bc334658dcbf"); // config...
        RequestCallback<LoginInfo> callback =
                new RequestCallback<LoginInfo>() {
                    @Override
                    public void onSuccess(LoginInfo param) {
                        LogUtils.loge(param.getAccount());
                    }

                    @Override
                    public void onFailed(int code) {
                        LogUtils.loge(String.valueOf(code));
                    }

                    @Override
                    public void onException(Throwable exception) {

                    }
                    // 可以在此保存LoginInfo到本地，下次启动APP做自动登录用
                };
        NIMClient.getService(AuthService.class).login(info)
                .setCallback(callback);
    }
}
